import React from 'react';

import './customerList.scss';
import UserCard from 'components/widget/user/UserCard'
import { getCustomerList } from '@/api/user';
import '../index/index.scss';
class ReportUserList extends React.Component{
	constructor (props) {
		super(props)
		this.state = {
			userList: [],
			rateName: [
				'',
				'0~50%',
				'50~80%',
				'80~90%', 
				'100%'
			]
		}
	}
	goBack () { //返回上一级
    this.props.history.goBack()
  }
	componentDidMount () {
		document.title = '我的报表'
		getCustomerList({type: this.props.location.state.type}).then(res => {
			console.log(res)
			this.setState({
				userList: res.data
			})
		})
	}
	render() {
		return(
			<div className='user-group'>
				{/*<div className="title">
          <div onClick={this.goBack.bind(this)}><i className="glyphicon glyphicon-left"></i></div>
          <div>我的报表</div>
          <div><i className="glyphicon glyphicon-options"></i></div>
        </div>*/}
				<div className='user-title'>预计成交率{this.state.rateName[this.props.location.state.type]}共有{this.state.userList.length}位客户</div>
				<div className={this.state.userList.length > 0 ? "user-list" : "user-list empty"}>
					{
						this.state.userList.length > 0 ? this.state.userList.map((item, index) => {
							return (
								<UserCard key={index} userDetail={item} />
							)
						}) : <div>-没有更多数据-</div>
					}
				</div>
			</div>
		)
	}
}
export default ReportUserList;
